﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ASPNET.StarterKit.BusinessLogicLayer;
using ASPNET.StarterKit.DataAccessLayer;


public partial class InventoryTracker_MaterialMaster1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnMatSubmit_Click(object sender, EventArgs e)
    {
        if (txtMatLength.Text == null || txtMatLength.Text == "")
        {
            txtMatLength.Text = "0";
        }
        if (txtMatWidth.Text == null || txtMatWidth.Text == "")
        {
            txtMatWidth.Text = "0";
        }
        if (txtMatHeigth.Text == null || txtMatHeigth.Text == "")
        {
            txtMatHeigth.Text = "0";
        }
        if (txtMatWeight.Text == null || txtMatWeight.Text == "")
        {
            txtMatWeight.Text = "0";
        }
            DataAccess DA = DataAccessHelper.GetDataAccess();
            Material aMaterial = new Material(txtMatItemName.Text,txtMatItemDescription.Text,
                txtMatItemType.Text,txtMatItemCategory.Text,ddruomID.SelectedIndex, int.Parse(txtMatLength.Text),int.Parse( txtMatWidth.Text),int.Parse(txtMatHeigth.Text),int.Parse(txtMatWeight.Text),int.Parse( txtMatReorderQty.Text),
                int.Parse( txtReorderPoint.Text),int.Parse( txtMatSellingRate.Text),ddrLocationID.SelectedIndex);
            try
            {
                
                if (DA.CreateMaterial(aMaterial))
                {
                    lblResult.Text = "Success";
                }
                else
                {
                    lblResult.Text = "Failure";
                }
            }
            catch (Exception ex)
            {
                lblResult.Text = ex.Message.ToString();
            }
        }


    }

